<template>
	<view class="all-box containers">

		<!-- 底下部分 -->
		<view class=" Agent-buttom">
			<view class="Agent-buttom-title">
				<view class="name">
					人员名单
				</view>
				<view class="rs">
					成员数量：{{data.count || 0}}
				</view>
			</view>
			<view class="agent-list" v-if="data.info.level == 0">
				<view :class="level==0?'agent-nav agent-nav-check':'agent-nav' " @tap.stop="checkLevel(0)">全部</view>
				<view :class="level==1?'agent-nav agent-nav-check':'agent-nav' " @tap.stop="checkLevel(1)">区域代理</view>
				<view :class="level==2?'agent-nav agent-nav-check':'agent-nav' " @tap.stop="checkLevel(2)">推广员</view>
			</view>
			<view class="nogoods" v-if="data.total ==0">

				<view>
					<view class="img">
						<image :src="OSS_HOST+'img/no-goods.png'" mode=""></image>
					</view>
				</view>
			</view>
			<view class="Agent-buttom-centent" v-for="item in data.list">
				<view class="Bt" style="">
					<view class="">
						<image :src="OSS_HOST+'img/demo-head.png'"></image>
					</view>
					<view class="left">
						<view class="name">
							{{item.nickname}}
						</view>
						<view class="time">
							手机号:{{item.tel}}&nbsp;&nbsp;&nbsp;推广数量{{item.count || 0}}
						</view>
					</view>
				</view>
				<view class="right">
					<text class="iconfont " @click="GoRyGl('popularize',item)">&#xe661;</text>
					<text class="iconfont " @click="GoRyGl('Personnelmanagement',item)">&#xe664;</text>
				</view>
			</view>
		</view>
		
		
		<!-- <New_personnel ref="personnel"></New_personnel> -->
		<uni-popup ref="buyerModel" type="center" custom="true">
			<view class="vipCard-box" @tap.stop="toVipCard()">
				<view class="img">
					<image :src="OSS_HOST+'img/buyer.png'" width="720rpx" mode="aspectFill"></image>
				</view>
				<view class="close">
					<text class="iconfont" @tap.stop="$refs['buyerModel'].close()">&#xe621;</text>
				</view>
			</view>
		</uni-popup>



	</view>
</template>
<script>
	// 骨架屏
	import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
	// 气泡框
	// import bubblePopup from '@/components/tui-bubble-popup/tui-bubble-popup.vue'
	// 引入最下面的线
	// import tuiDivider from "@/components/divider/divider.vue"
	//下拉组件
	// import uniLoadMore from '@/components/uni-load-more.vue';
	// import tuiListCell from "@/components/list-cell/list-cell"
	// import uniPopup from '@/components/uni-popup/uni-popup.vue'
	// import tuiButton from '@/components/button/button.vue'
	// import hxNavbar from '@/components/hx-navbar/hx-navbar'
	// import New_personnel from "@/components/Newmessage/New_personnel"
	import Vue from 'vue'
	import jsCookies from '@/node_modules/js-cookie'
	import store from '@/store/index.js';
	import {
		oss_host
	} from '@/config/config.js';
	// 公共底部
	// import btabbar from '@/components/indexBottomTable/bottomtabbar.vue'
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
	import {
		mapGetters
	} from 'vuex';

	// 按需加载
	export default {


		components: {
			// tuiModal,
			uniPopup,
			// btabbar,
			// tuiListCell,
			// tuiDivider,
			// uniLoadMore,
			// tuiButton,
			// bubblePopup,
			// tuiSkeleton,
			// New_personnel
		},
		data() {
			return {

				isTop: 0,
				navConfig: {
					// business-enter-nav.png
					backgroundImg: 'https://xoimg.aiouning.com/static/img/business-enter-nav.png',
					// title:'申请列表',
					color: '#fff',
					fontSize: 12,
					back: true,
					height: 55


				},

				// 图片链接站点
				OSS_HOST: oss_host,
				contentText: {
					contentdown: '上拉显示更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了',
					contentfirst: "暂无数据"
				},
				reason: '',
				check_estate: false,
				id: '',

				level:0,

				message: "",

				//接口数据
				data: {

					list: []


				},

				cartsListHeight: 400, //动态高度
				calcullateHeight: 400, //固定高度，计算需要
				current: 0,


				curr_page: 0,
				last_page: 0,


				// 骨架屏
				skeletonShow: true
			}
		},

		computed: {
			//注册网络状态
			...mapGetters(['netWorkType', 'loginStatus'])
		},
		onPageScroll: function(e) {

			if (e.scrollTop > 300) {
				this.isTop = 1
			} else {
				this.isTop = 0
			}
		},
		onLoad: function(e) {

			let that = this;

			//that.$refs.popupvLogin.open()
			//  高度自适应
			uni.getSystemInfo({
				success: function(res) {
					// console.log(res)
					let calc = res.windowHeight;
					that.winHeight = calc;
				}
			});
			//#ifdef  MP-WEIXIN
			that.navHeight = 44;
			//#endif

		},
		//页面初始
		onShow() {
			this.curr_page = 0
			this.getList()



		},
		onPullDownRefresh: function() {
			//下拉刷新的时候请求一次数据
			//console.log(11)
			this.curr_page = 0
			// this.loadingType = 3;				
			// this.getList();


		},
		onReachBottom: function() {
			//触底的时候请求数据，即为上拉加载更多
			//为了更加清楚的看到效果，添加了定时器
			//console.log(this.curr_page)

			if (this.curr_page >= this.last_page) {
				uni.showToast({
					icon: 'none',
					title: '没有更多数据'
				});

				// this.loadingType = 2;				
				return;
			}

			this.loadingType = 1;
			// 正常应为:
			this.getList();
		},

		methods: {

			refresh() {
				this.getList()
			},
			getList() {
				let _this = this
				//提交ajax
				// console.log(1111)
				var opt = {
					url: '/assert/assertList',
					data: {
						page: ++_this.curr_page,
						level:_this.level||''
					},
					success: function(res) {
						if (res.status == 1) {
							// _this.data.list = res.data.list
							_this.data.info = res.data.info
							_this.last_page = res.data.total
							_this.data.total = res.data.total
							_this.data.count = res.data.count
							if(_this.curr_page>1){
								_this.data.list =_this.data.list.concat(res.data.list)
								
							}else {
								 _this.data.list = res.data.list
							}
							
						} else {
							_this.data.list = []

						}

					}
				};
				this.$service.GetApi(opt) //网络	

			},
			checkLevel(level){
				let _this = this 
				_this.level = level
				_this.curr_page = 0;
				_this.getList();
			},

			GoRyGl(type, item) {
				let items = encodeURIComponent(JSON.stringify(item));
				if (type == 'popularize') {
					uni.navigateTo({
						url: '/packageAgent/pages/popularize/popularize?itemlist=' + items+'&level='+this.data.info.level
					})

				} else if (type == 'Personnelmanagement') {
					uni.navigateTo({
						url: '/packageAgent/pages/Personnelmanagement/Personnelmanagement?itemlist=' + items+'&level='+this.data.info.level
					})

				}
			},

			addpersonnel() {


				this.$refs.buyerModel.open()
			},

		}
	}
</script>

<style lang="scss">
	@import "./personnel.scss";
</style>